# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Alad Wenter <alad@mailbox.org>
# Contributor: Eric Biggers <ebiggers3 at gmail dot com>

pkgname=wimlib
pkgver=1.14.3
pkgrel=1
pkgdesc='A library and program to extract, create, and modify WIM files'
arch=('loong64' 'x86_64')
url='https://wimlib.net'
license=('custom')
depends=('fuse3' 'ntfs-3g')
makedepends=('git')
checkdepends=('attr')
optdepends=(
  'cdrkit: for making ISO image of Windows PE'
  'mtools: for making disk image of Windows PE' 
  'syslinux: for making disk image of Windows PE'
  'cabextract: for extracting Windows PE from the WAIK'
)
provides=('libwim.so')
_commit='4baa0ab7b8ad5c7f0a109e22e9a6c8621a7edd42'
source=("$pkgname::git+https://github.com/ebiggers/wimlib#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  autoreconf -i

  ./configure \
    --disable-static \
    --with-libcrypto \
    --with-fuse \
    --with-ntfs-3g \
    --prefix=/usr

  make
}

check() {
  cd "$pkgname"

  make check
}

package() {
  cd "$pkgname"

  make DESTDIR="$pkgdir" install

  # documentation
  install -Dm644 {NEWS,README}.md -t "$pkgdir/usr/share/doc/$pkgname"

  # licenses
  install -Dm644 COPYING* -t "$pkgdir/usr/share/licenses/$pkgname"
}
